<!DOCTYPE html>
<html>

<meta charset="utf-8"> 
<head>
	<title data-localize="test.title">测试机</title>
<link rel="stylesheet" type="text/css" href="css/common.css">
<style type="text/css">
p{
	margin: 0;
}
.u-line{
	margin: 0 auto;
	width: 770px;
    height: 600px;
    overflow: hidden;
}
.u-road{
	position: relative;
	height: 200px;
	width: 890px;
	float: right;
	margin-top: 110px;
	-webkit-transform: rotateY(180deg);
}
.u-road p{
	-webkit-transform: rotateY(180deg);
}
.u-road span{
	display: inline-block;
	-webkit-transform: rotateY(180deg);
}
.opposite{
	margin-top: 0;
	-webkit-transform: rotateX(180deg) rotateY(180deg);
}
.opposite p{
	-webkit-transform: rotateX(180deg) rotateY(180deg);
}
.opposite span{
	display: inline-block;
	-webkit-transform: rotateX(180deg) rotateY(180deg);
}
.u-road-opposite{
	position: relative;
	height: 200px;
	width: 770px;
	float: left;
	margin-top: 110px;
	-webkit-transform: rotateY(180deg);
}
.u-roadcon{
	position: relative;
	float: left;
}
.u-roadcon:after{
	content: '';
	display: block;
	clear: both;
}
.u-road:after{
	content: '';
	display: block;
	clear: both;
}
.u-road-opposite:after{
	content: '';
	display: block;
	clear: both;
}
.u-track{
	position: absolute;
	height: 28px;
	width: 100%;
	left: 0;
	top: 85px;
	border-top: 1px solid #cecece;
	border-bottom: 1px solid #cecece;
}
.u-outtrack{
	position: absolute;
	height: 52px;
	width: 28px;
	left: 550px;
	top: 33px;
	border-left: 1px solid #cecece;
	border-right: 1px solid #cecece;
}
.u-adjust2{
	position: absolute;
	left: 410px;
	width: 71px;
	height: 20px;
}
.u-adjust1{
	position: absolute;
	left: 650px;
	width: 71px;
	height: 20px;
}
.u-test{
	position: absolute;
	left: 290px;
	top: -35px;
	width: 68px;
	height: 68px;
	background: #eef2f7;
	border-radius: 4px;
	border: 1px solid #29abe2;
	z-index: 10;
}
.u-test p{
	margin: 0;
	text-align: center;
	font-size: 16px;
	line-height: 68px;
}
/*animations*/
.stop {
    animation-play-state: paused;
}

</style>
<link rel="stylesheet" type="text/css" href="css/machine.css">
</head>
<body>
<div class='u-head'>
   <div class="u-headcon">
	<a href="index.html"><div class="u-mainpage" data-localize="back">回到首页</div></a>
	<h3 data-localize="test.title">测试机</h3>
	<div class="changeLang">
		<p class="u-lang"><span>中文</span><span>English</span></p>
	    <div isopen="true" class="changeLangBtn"></div>
	</div>
</div>
</div>
<div class="u-infos">
	<h2 data-localize="test.info_title">状态区域</h2>
	<div class="u-errorlist">
		<h3 data-localize="yichang">异常一览：</h3>
		<div class="u-errorlistcon">
		</div>
	</div>
	<p class="status"><span data-localize="test.running">运行状态：</span><span class="u-cube t-status"></span></p>
</div>
<div class="t-con">
<div class="u-line">
	<div class="u-boxcon needleft u-boxconspe" id="u-boxe"><div class="u-box u-boxe"></div></div>
	<div class="u-road lineA">
		<div class="u-adjust1 u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust1 u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust2 u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust2 u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-track"></div>
		<div class="u-test"><p data-localize="test.testbox">测试机</p></div>
		<div class="u-boxcon stop"><div class="u-box u-box6"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box5"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box4"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box3"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box2"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box1"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box1"></div></div>
	</div>
	<div class="u-road opposite lineB">
		<div class="u-adjust1 u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust1 u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust2 u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust2 u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-track"></div>
		<div class="u-test"><p data-localize="test.testbox">测试机</p></div>
		<div class="u-boxcon stop"><div class="u-box u-box6"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box5"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box4"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box3"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box2"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box1"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box1"></div></div>
	</div>
</div>
</div>
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/language_cookie.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var lastData = null,
	si=null,
	isFirst = true;
var url = getUrl("test");
var request = new GetRequest();
var showval= request.type; 
if ('WebSocket' in window) {
    websocket = new WebSocket(url+'/'+request.line+'/'+request.index);
}else {
    alert('Not support websocket')
}
if (request.line == "A") {
	$('.lineB').hide();
	$('.lineA').show();
}else if (request.line == "B") {
	$('.lineA').hide();
	$('.lineB').show();
}
websocket.onerror = function () {
    $('.u-boxcon,.u-adjust').addClass('stop');
    $('.u-box4').addClass('stop');
};

websocket.onopen = function (event) {
    $('.u-boxcon,.u-adjust').removeClass('stop');
    $('.u-box4').removeClass('stop');
    $('.u-box3').removeClass('break');
}

websocket.onmessage = function (event) {
    $('#u-boxe').addClass('moveleft');
    //si,获取推送数据
    si = JSON.parse(event.data.replace(/\bNaN\b/g, "null"));
    //赋值lastData
    if (!lastData) {
    	lastData = si;
    }
    //判断是不是第一次跑
    if (isFirst) {
    	count(si.stack_list);
		isFirst = false;
    }
    //夹片
    if (si.isPause1 == 0) {
    	$('.u-adjust1.u-adjusttop').addClass('u-adjustup');
    	$('.u-adjust1.u-adjustbottom').addClass('u-adjustdown');
    }else if (si.isPause1 == 1) {
    	$('.u-adjust1.u-adjusttop').removeClass('u-adjustup');
    	$('.u-adjust1.u-adjustbottom').removeClass('u-adjustdown');
    }
    if (si.isPause2 == 0) {
    	$('.u-adjust2.u-adjusttop').addClass('u-adjustup');
    	$('.u-adjust2.u-adjustbottom').addClass('u-adjustdown');
    }else if (si.isPause2 == 1) {
    	$('.u-adjust2.u-adjusttop').removeClass('u-adjustup');
    	$('.u-adjust2.u-adjustbottom').removeClass('u-adjustdown');
    }

    //错误报告
    errorRender();
    //移动片子
    addanimate(si.stack_list);
    console.log(si);
    // 运行状态变色
    changeColor($('.t-status'),si.p2);
    //当前数据si置换为上条数据lastData
    lastData = si;
}
//移除动画效果
document.getElementById('u-boxe').addEventListener("webkitAnimationIteration", function(){
	reset();
	count(si.stack_list);
    $('.u-boxcon').removeClass('moveleft');
}, false);
//页面关闭时关闭websocket
window.onbeforeunload = function(){
	websocket.close();
}  
</script>
</body>
</html>